package com.hyt.it.ogt.ykcj.service.grade.impl;

import com.hyt.exception.exception.BusinessLogicException;
import com.hyt.it.ogt.common.config.GlobalConfig;
import com.hyt.it.ogt.ykcj.common.core.domain.entity.SysDictData;
import com.hyt.it.ogt.ykcj.common.enums.CommonEnums;
import com.hyt.it.ogt.ykcj.common.enums.ExamResultDownLoadFileTypeEnum;
import com.hyt.it.ogt.ykcj.common.exception.CustomException;
import com.hyt.it.ogt.ykcj.domain.exam.ExamInfo;
import com.hyt.it.ogt.ykcj.domain.exam.ExamNameConfig;
import com.hyt.it.ogt.ykcj.domain.exam.ExamSubjectInfo;
import com.hyt.it.ogt.ykcj.domain.exam.ExamSubjectNameConfig;
import com.hyt.it.ogt.ykcj.domain.vo.EnterpriseExamineeExamGradeVo;
import com.hyt.it.ogt.ykcj.domain.vo.QueryEnterpriseExamineeGradeVo;
import com.hyt.it.ogt.ykcj.domain.vo.export.ExportEnterpriseExamineeScoreVo;
import com.hyt.it.ogt.ykcj.domain.vo.export.ExportEnterpriseExamineeStemScoreVo;
import com.hyt.it.ogt.ykcj.domain.vo.export.ExportEnterpriseExamineeSubjectGradeScoreVo;
import com.hyt.it.ogt.ykcj.mapper.exam.*;
import com.hyt.it.ogt.ykcj.mapper.grade.EnterpriseExamineeInfoMapper;
import com.hyt.it.ogt.ykcj.mapper.grade.EnterpriseExamineeSubjectGradeMapper;
import com.hyt.it.ogt.ykcj.mapper.system.SysDictDataMapper;
import com.hyt.it.ogt.ykcj.service.exam.IClassificationService;
import com.hyt.it.ogt.ykcj.service.exam.IExamResultDataDownLoadRecordService;
import com.hyt.it.ogt.ykcj.service.grade.IEnterpriseExamineeGradeExportService;
import com.hyt.it.ogt.ykcj.service.system.ISysDictDataService;
import com.hyt.loginfo.model.User;
import com.hyt.progress.service.ProgressManager;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 企业招聘考生成绩导入Service业务层处理
 *
 * @author liying
 * @date 2021-11-26
 */
@Service
public class EnterpriseExamineeGradeExportServiceImpl implements IEnterpriseExamineeGradeExportService {

    private static final Logger log = LoggerFactory.getLogger(EnterpriseExamineeGradeExportServiceImpl.class);
    @Autowired
    private EnterpriseExamineeInfoMapper enterpriseExamineeInfoMapper;

    @Autowired
    private ExamInfoMapper examInfoMapper;

    @Autowired
    private ExamNameConfigMapper examNameConfigMapper;

    @Autowired
    private ExamSubjectNameConfigMapper examSubjectNameConfigMapper;

    @Autowired
    private ExamSubjectInfoMapper examSubjectInfoMapper;

    @Autowired
    private SysDictDataMapper selectDictDataMap;

    @Autowired
    private ExamStemInfoMapper examStemInfoMapper;

    @Autowired
    private ISysDictDataService dictDataService;


    @Autowired
    private IClassificationService classificationService;

    @Autowired
    private IExamResultDataDownLoadRecordService examResultDataDownLoadRecordService;

    @Autowired
    private EnterpriseExamineeInfoExportUtil enterpriseExamineeInfoExportUtil;

    @Resource
    GlobalConfig globalConfig;

    @Autowired
    private EnterpriseExamineeSubjectGradeMapper enterpriseExamineeSubjectGradeMapper;


    @Override
    public void exportExcelByCondition(QueryEnterpriseExamineeGradeVo queryEnterpriseExamineeGradeVo, User user, ExamResultDownLoadFileTypeEnum fileType) throws Exception {
        // 判断考试是否存在
        ExamInfo examInfo = examInfoMapper.selectExamInfoById(queryEnterpriseExamineeGradeVo.getExamId());
        if (examInfo == null || StringUtils.isEmpty(examInfo.getId()) || StringUtils.isEmpty(examInfo.getExamNameConfigId())) {
            BusinessLogicException.throwException(52292106, "所选考试不存在");
        }
        ProgressManager.updateProgressCurrent(5, "获取考试信息完成");

        String examNameConfigId = examInfo.getExamNameConfigId();
        ExamNameConfig examNameConfig = examNameConfigMapper.selectExamNameConfigById(examNameConfigId);
        if (examNameConfig == null || StringUtils.isEmpty(examNameConfig.getName())) {
            BusinessLogicException.throwException(52292107, "所选考试名称配置信息不存在");
        }
        ProgressManager.updateProgressCurrent(10, "获取考试配置完成");

        // zip文件URL
        String dbfUrl = null;
        try {
            // 设置导出时候的名称
            queryEnterpriseExamineeGradeVo.setFileName(System.currentTimeMillis() + "_" + examNameConfig.getName() + "_" + "成绩");
            queryEnterpriseExamineeGradeVo.setSheetName(examNameConfig.getName() + "成绩列表");

            // 一：（查询表格头）获取考试的科目,存在查询不到学生信息的情况，用这个考试科目的内容来构建excel的列的表头
            List<ExportEnterpriseExamineeSubjectGradeScoreVo> subjectList = getSubjectList(queryEnterpriseExamineeGradeVo.getExamId(), null);
            ProgressManager.updateProgressCurrent(15, "查询表格头完成");

            // 二：（查询表格内容）如果传了考生id：则导出考生的考试题干成绩 ； 如果没传考生id：
            List<ExportEnterpriseExamineeScoreVo> enterpriseExamineeScoreVos = null;
            if (null != queryEnterpriseExamineeGradeVo.getExamineeIds() && queryEnterpriseExamineeGradeVo.getExamineeIds().length > 0) {
                Map<String, Object> examineeParms = new HashMap<>();
                examineeParms.put("deptIds", queryEnterpriseExamineeGradeVo.getDeptIds());
                examineeParms.put("examineeIds", queryEnterpriseExamineeGradeVo.getExamineeIds());
                examineeParms.put("examId", queryEnterpriseExamineeGradeVo.getExamId());
                examineeParms.put("examineeName", queryEnterpriseExamineeGradeVo.getExamineeName());
                // 查询条件添加进去
                examineeParms.putIfAbsent("qualifiedStatus", queryEnterpriseExamineeGradeVo.getQualifiedStatus());
                examineeParms.putIfAbsent("archivedStatus", queryEnterpriseExamineeGradeVo.getArchivedStatus());
                List<EnterpriseExamineeExamGradeVo> enterpriseExamineeSubjectGradeVos = enterpriseExamineeSubjectGradeMapper.selectEnterpriseSubjectExamineeByParms(examineeParms);
                //总成绩 key examineeId
                Map<String, List<EnterpriseExamineeExamGradeVo>> subjectGradeMap = enterpriseExamineeSubjectGradeVos.stream().collect(Collectors.groupingBy(c -> c.getExamineeId()));
                enterpriseExamineeScoreVos = getExportEnterpriseExamineeScoreVos(subjectGradeMap, queryEnterpriseExamineeGradeVo.getQualifiedStatus(), queryEnterpriseExamineeGradeVo.getRegionName());
            } else {
                Map<String, Object> examineeParms = new HashMap<>();
                examineeParms.put("deptIds", queryEnterpriseExamineeGradeVo.getDeptIds());
                examineeParms.put("examId", queryEnterpriseExamineeGradeVo.getExamId());
                examineeParms.put("examineeName", queryEnterpriseExamineeGradeVo.getExamineeName());
                // 查询条件添加进去
                examineeParms.putIfAbsent("qualifiedStatus", queryEnterpriseExamineeGradeVo.getQualifiedStatus());
                examineeParms.putIfAbsent("archivedStatus", queryEnterpriseExamineeGradeVo.getArchivedStatus());
                List<EnterpriseExamineeExamGradeVo> enterpriseExamineeSubjectGradeVos = enterpriseExamineeSubjectGradeMapper.selectEnterpriseSubjectExamineeByParms(examineeParms);
                //总成绩 key examineeId
                Map<String, List<EnterpriseExamineeExamGradeVo>> subjectGradeMap = enterpriseExamineeSubjectGradeVos.stream().collect(Collectors.groupingBy(c -> c.getExamineeId()));
                enterpriseExamineeScoreVos = getExportEnterpriseExamineeScoreVos(subjectGradeMap, queryEnterpriseExamineeGradeVo.getQualifiedStatus(), queryEnterpriseExamineeGradeVo.getRegionName());
            }
            ProgressManager.updateProgressCurrent(20, "查询表格内容完成");

            // 5：设置学历、性别
            bulidEducationAndSex(enterpriseExamineeScoreVos);
            ProgressManager.updateProgressCurrent(21, "设置学历、性别完成");

            XSSFWorkbook xssfWorkbook = EnterpriseExamineeInfoExportUtil.getExamineeSubjectXSSFWorkbook(enterpriseExamineeScoreVos, subjectList, queryEnterpriseExamineeGradeVo.getSheetName());
            ProgressManager.updateProgressCurrent(30, "生成Excel文件完成");

            dbfUrl = enterpriseExamineeInfoExportUtil.exportExcelV2(xssfWorkbook, queryEnterpriseExamineeGradeVo.getFileName());
            ProgressManager.updateProgressCurrent(40, "文件上传华为云完成");
        } catch (Exception e) {
            log.error("# 23、上传{}文件异常", queryEnterpriseExamineeGradeVo.getFileName(), e);
        }

        if (StringUtils.isEmpty(dbfUrl)) {
            BusinessLogicException.throwException(52292108, "文件生成失败");
        }
        ProgressManager.finish(dbfUrl);
    }


    @Override
    public void exportSubjectExcelByCondition(QueryEnterpriseExamineeGradeVo queryEnterpriseExamineeGradeVo, User user, ExamResultDownLoadFileTypeEnum fileType) throws Exception {
        //判断考试是否存在
        ExamInfo examInfo = examInfoMapper.selectExamInfoById(queryEnterpriseExamineeGradeVo.getExamId());
        if (examInfo == null || StringUtils.isEmpty(examInfo.getId())) {
            BusinessLogicException.throwException(52293104, "所选考试不存在");
        }
        ProgressManager.updateProgressCurrent(5, "获取考试信息完成");

        //判断考试是否存在
        ExamSubjectInfo examSubjectInfo = examSubjectInfoMapper.selectExamSubjectInfoById(queryEnterpriseExamineeGradeVo.getSubjectId());
        if (examSubjectInfo == null || StringUtils.isEmpty(examSubjectInfo.getExamInfoId())) {
            BusinessLogicException.throwException(52293105, "所选科目不存在");
        }
        ProgressManager.updateProgressCurrent(10, "获取所选科目完成");

        // zip文件URL
        String dbfUrl = null;
        try {
            //设置导出时候的名称
            ExamSubjectNameConfig examSubjectNameConfig = examSubjectNameConfigMapper.selectExamSubjectNameConfigById(examSubjectInfo.getExamSubjectNameId());
            ProgressManager.updateProgressCurrent(15, "获取导出名称完成");

            queryEnterpriseExamineeGradeVo.setFileName(examSubjectNameConfig.getName() + "成绩");
            queryEnterpriseExamineeGradeVo.setSheetName(examSubjectNameConfig.getName() + "成绩列表");
            //一：（查询表格头）获取考试的科目,存在查询不到学生信息的情况，用这个考试科目的内容来构建excel的列的表头
            List<ExportEnterpriseExamineeSubjectGradeScoreVo> subjectList = getSubjectList(queryEnterpriseExamineeGradeVo.getExamId(), queryEnterpriseExamineeGradeVo.getSubjectId());
            ProgressManager.updateProgressCurrent(20, "查询表格头完成");

            //二：（查询表格内容）如果传了考生id：则导出考生的考试题干成绩  ； 如果没传考生id：则导出该场考试的全部学生的考试题干成绩
            List<ExportEnterpriseExamineeScoreVo> enterpriseExamineeScoreVos = null;
            if (null != queryEnterpriseExamineeGradeVo.getExamineeIds() && queryEnterpriseExamineeGradeVo.getExamineeIds().length > 0) {
                Map<String, Object> examineeParms = new HashMap<>();
                examineeParms.put("deptIds", queryEnterpriseExamineeGradeVo.getDeptIds());
                examineeParms.put("examineeIds", queryEnterpriseExamineeGradeVo.getExamineeIds());
                examineeParms.put("examId", queryEnterpriseExamineeGradeVo.getExamId());
                //            examineeParms.put("qualifiedStatus",queryEnterpriseExamineeGradeVo.getQualifiedStatus());
                //            examineeParms.put("regionName",queryEnterpriseExamineeGradeVo.getRegionName());
                examineeParms.put("archivedStatus", queryEnterpriseExamineeGradeVo.getArchivedStatus());
                examineeParms.put("examineeName", queryEnterpriseExamineeGradeVo.getExamineeName());
                examineeParms.put("subjectId", queryEnterpriseExamineeGradeVo.getSubjectId());
                List<EnterpriseExamineeExamGradeVo> enterpriseExamineeSubjectGradeVos = enterpriseExamineeSubjectGradeMapper.selectSubjectEnterpriseExamineeByParms(examineeParms);
                //总成绩 key examineeId
                Map<String, List<EnterpriseExamineeExamGradeVo>> subjectGradeMap = enterpriseExamineeSubjectGradeVos.stream().collect(Collectors.groupingBy(c -> c.getExamineeId()));
                enterpriseExamineeScoreVos = getExportEnterpriseExamineeScoreVos(subjectGradeMap, queryEnterpriseExamineeGradeVo.getQualifiedStatus(), queryEnterpriseExamineeGradeVo.getRegionName());
            } else {
                Map<String, Object> examineeParms = new HashMap<>();
                examineeParms.put("deptIds", queryEnterpriseExamineeGradeVo.getDeptIds());
                examineeParms.put("examId", queryEnterpriseExamineeGradeVo.getExamId());
                //            examineeParms.put("qualifiedStatus",queryEnterpriseExamineeGradeVo.getQualifiedStatus());
                //            examineeParms.put("regionName",queryEnterpriseExamineeGradeVo.getRegionName());
                examineeParms.put("archivedStatus", queryEnterpriseExamineeGradeVo.getArchivedStatus());
                examineeParms.put("examineeName", queryEnterpriseExamineeGradeVo.getExamineeName());
                examineeParms.put("subjectId", queryEnterpriseExamineeGradeVo.getSubjectId());
                List<EnterpriseExamineeExamGradeVo> enterpriseExamineeSubjectGradeVos = enterpriseExamineeSubjectGradeMapper.selectSubjectEnterpriseExamineeByParms(examineeParms);
                //总成绩 key examineeId
                Map<String, List<EnterpriseExamineeExamGradeVo>> subjectGradeMap = enterpriseExamineeSubjectGradeVos.stream().collect(Collectors.groupingBy(c -> c.getExamineeId()));
                enterpriseExamineeScoreVos = getExportEnterpriseExamineeScoreVos(subjectGradeMap, queryEnterpriseExamineeGradeVo.getQualifiedStatus(), queryEnterpriseExamineeGradeVo.getRegionName());
            }
            ProgressManager.updateProgressCurrent(40, "查询表格内容完成");

            //5：设置总成绩 、学历、性别
            bulidEducationAndSex(enterpriseExamineeScoreVos);
            ProgressManager.updateProgressCurrent(45, "设置总成绩 、学历、性别完成");

            XSSFWorkbook xssfWorkbook = EnterpriseExamineeInfoExportUtil.getExamineeSinglSubjectXSSFWorkbook(enterpriseExamineeScoreVos, subjectList, queryEnterpriseExamineeGradeVo.getSheetName());
            ProgressManager.updateProgressCurrent(50, "Excel生成完成");

            dbfUrl = enterpriseExamineeInfoExportUtil.exportExcelV2(xssfWorkbook, queryEnterpriseExamineeGradeVo.getFileName());
            ProgressManager.updateProgressCurrent(60, "华为云文件上传完成");
        } catch (Exception e) {
            log.error("# 23、上传{}文件异常", queryEnterpriseExamineeGradeVo.getFileName(), e);
        }
        
        if (StringUtils.isEmpty(dbfUrl)) {
            BusinessLogicException.throwException(52293106, "文件生成失败");
        }
        ProgressManager.finish(dbfUrl);
    }

    @Override
    public XSSFWorkbook getExamTpl(String examId, String subject) {

        //判断考试是否存在
        ExamInfo examInfo = examInfoMapper.selectExamInfoById(examId);
        if (examInfo == null || org.springframework.util.StringUtils.isEmpty(examInfo.getId())) {
            throw new CustomException("查询的考试不存在！");
        }

        //获取性别和学历的内容
        Map<String, String> sexDataMap = dictDataService.selectDictDataMap("sys_user_sex", "V");
        Map<String, String> educationDataMap = dictDataService.selectDictDataMap("education", "V");
        List<String> sexKeyList = new ArrayList<>();
        for (String key : sexDataMap.keySet()) {
            sexKeyList.add(key);
        }
        String[] sexKeys = new String[sexKeyList.size()];
        for (int i = 0; i < sexKeys.length; i++) {
            sexKeys[i] = sexKeyList.get(i);
        }
        List<String> educationKeyList = new ArrayList<>();
        for (String key : educationDataMap.keySet()) {
            educationKeyList.add(key);
        }
        String[] educationKeys = new String[educationKeyList.size()];
        for (int i = 0; i < educationKeys.length; i++) {
            educationKeys[i] = educationKeyList.get(i);
        }

        //获取要导出得科目及其题干内容
        List<ExportEnterpriseExamineeSubjectGradeScoreVo> subjectList = enterpriseExamineeInfoMapper.getExamSubject(examId, subject);

        return EnterpriseExamineeInfoExportUtil.getExportTep(subjectList, CommonEnums.EXPORT_IMPORT_SUBJECT_SHEET_NAME.getDesc(), sexKeys, educationKeys);
    }


    private List<ExportEnterpriseExamineeScoreVo> getExportEnterpriseExamineeScoreVos(Map<String, List<EnterpriseExamineeExamGradeVo>> subjectGradeMap, String qualifiedStatus, String regionName) {
        List<ExportEnterpriseExamineeScoreVo> enterpriseExamineeScoreVos = new ArrayList<>();
        for (String key : subjectGradeMap.keySet()) {
            List<EnterpriseExamineeExamGradeVo> enterpriseExamineeExamGradeVos = subjectGradeMap.get(key);
            if (CollectionUtils.isEmpty(enterpriseExamineeExamGradeVos)) {
                continue;
            }
            List<String> qualifiedStatuss = enterpriseExamineeExamGradeVos.stream().filter(e -> StringUtils.isEmpty(e.getStemId())).filter(e -> StringUtils.isNotEmpty(e.getQualifiedStatus())).map(e -> e.getQualifiedStatus()).collect(Collectors.toList());
            List<String> regionNames = enterpriseExamineeExamGradeVos.stream().filter(e -> StringUtils.isEmpty(e.getStemId())).filter(e -> StringUtils.isNotEmpty(e.getRegionName())).map(e -> e.getRegionName()).collect(Collectors.toList());

            if (StringUtils.isNotEmpty(qualifiedStatus)) {
                if (CollectionUtils.isEmpty(qualifiedStatuss)) {
                    continue;
                }
                if (!qualifiedStatuss.contains(qualifiedStatus)) {
                    continue;
                }
            }
            if (StringUtils.isNotEmpty(regionName)) {
                if (CollectionUtils.isEmpty(regionNames)) {
                    continue;
                }
                if (!regionNames.contains(regionName)) {
                    continue;
                }
            }
            EnterpriseExamineeExamGradeVo vo = enterpriseExamineeExamGradeVos.get(0);
            ExportEnterpriseExamineeScoreVo exportEnterpriseExamineeScoreVo = new ExportEnterpriseExamineeScoreVo();
            if (CommonEnums.QUALIFIED_STATUS_Y.getCode().equals(vo.getQualifiedStatus())) {
                exportEnterpriseExamineeScoreVo.setQualifiedStatus(CommonEnums.QUALIFIED_STATUS_Y.getDesc());
            } else if (CommonEnums.QUALIFIED_STATUS_N.getCode().equals(vo.getQualifiedStatus())) {
                exportEnterpriseExamineeScoreVo.setQualifiedStatus(CommonEnums.QUALIFIED_STATUS_N.getDesc());
            } else {
                exportEnterpriseExamineeScoreVo.setQualifiedStatus("--");
            }
            if (StringUtils.isNotEmpty(vo.getRegionName())) {
                exportEnterpriseExamineeScoreVo.setQualifiedStatus(vo.getRegionName());
            }
            exportEnterpriseExamineeScoreVo.setEducation(vo.getEducation());
            exportEnterpriseExamineeScoreVo.setSex(vo.getSex());
            exportEnterpriseExamineeScoreVo.setTotalScore((enterpriseExamineeExamGradeVos.stream().filter(e -> StringUtils.isEmpty(e.getStemId())).filter(e -> null != e.getScore()).map(EnterpriseExamineeExamGradeVo::getScore).reduce(BigDecimal.ZERO, BigDecimal::add)));
            exportEnterpriseExamineeScoreVo.setAdmissionNo(vo.getAdmissionNo());
            exportEnterpriseExamineeScoreVo.setId(vo.getExamineeId());
            exportEnterpriseExamineeScoreVo.setIdcard(vo.getIdCard());
            exportEnterpriseExamineeScoreVo.setMobile(vo.getMobile());
            exportEnterpriseExamineeScoreVo.setName(vo.getName());
            exportEnterpriseExamineeScoreVo.setRegionName(vo.getRegionName());
            List<ExportEnterpriseExamineeSubjectGradeScoreVo> gradeScoreVos = new ArrayList<>(enterpriseExamineeExamGradeVos.size());
            //全部的科目
            List<EnterpriseExamineeExamGradeVo> subjextExamineeExamGradeVos = enterpriseExamineeExamGradeVos.stream().filter(e -> StringUtils.isEmpty(e.getStemId())).collect(Collectors.toList());

            //全部的题目
            Map<String, List<EnterpriseExamineeExamGradeVo>> stemMap = enterpriseExamineeExamGradeVos.stream().filter(e -> StringUtils.isNotEmpty(e.getStemId())).collect(Collectors.groupingBy(c -> c.getSubjectId()));

            for (EnterpriseExamineeExamGradeVo examGradeVo : subjextExamineeExamGradeVos) {
                ExportEnterpriseExamineeSubjectGradeScoreVo gradeScoreVo = new ExportEnterpriseExamineeSubjectGradeScoreVo();
                gradeScoreVo.setSubjectId(examGradeVo.getSubjectId());
                gradeScoreVo.setSubjectScore(examGradeVo.getScore());
                if (MapUtils.isNotEmpty(stemMap) && CollectionUtils.isNotEmpty(stemMap.get(examGradeVo.getSubjectId()))) {
                    List<EnterpriseExamineeExamGradeVo> examGradeVos = stemMap.get(examGradeVo.getSubjectId());
                    List<ExportEnterpriseExamineeStemScoreVo> stemScoreVos = new ArrayList<>(examGradeVos.size());
                    for (EnterpriseExamineeExamGradeVo examineeExamGradeVo : examGradeVos) {
                        ExportEnterpriseExamineeStemScoreVo stemScoreVo = new ExportEnterpriseExamineeStemScoreVo();
                        stemScoreVo.setStemId(examineeExamGradeVo.getStemId());
                        stemScoreVo.setStemScore(examineeExamGradeVo.getScore());
                        stemScoreVos.add(stemScoreVo);
                    }
                    gradeScoreVo.setExportEnterpriseExamineeStemScoreVos(stemScoreVos);
                }

                gradeScoreVos.add(gradeScoreVo);
            }
            exportEnterpriseExamineeScoreVo.setExportEnterpriseExamineeSubjectGradeScoreVos(gradeScoreVos);
            enterpriseExamineeScoreVos.add(exportEnterpriseExamineeScoreVo);
        }
        return enterpriseExamineeScoreVos;
    }


    private List<ExportEnterpriseExamineeSubjectGradeScoreVo> getSubjectList(String examId, String subjectId) {
        List<ExportEnterpriseExamineeSubjectGradeScoreVo> subjectList = enterpriseExamineeInfoMapper.getExamSubject(examId, subjectId);
        return subjectList;
    }


    private void bulidEducationAndSex(List<ExportEnterpriseExamineeScoreVo> enterpriseExamineeScoreVos) {
        if (CollectionUtils.isEmpty(enterpriseExamineeScoreVos)) {
            return;
        }
        SysDictData dictData = new SysDictData();
        dictData.setDictType("education");
        List<SysDictData> educationDicList = selectDictDataMap.selectDictDataList(dictData);
        dictData.setDictType("sys_user_sex");
        List<SysDictData> sexDicList = selectDictDataMap.selectDictDataList(dictData);
        enterpriseExamineeScoreVos.stream().forEach(enterpriseExamineeScoreVo -> {
            educationDicList.stream().forEach(sysDictData -> {
                if (sysDictData.getDictValue().equals(enterpriseExamineeScoreVo.getEducation())) {
                    enterpriseExamineeScoreVo.setEducation(sysDictData.getDictLabel());
                    return;
                }
            });
            sexDicList.stream().forEach(sexDictData -> {
                if (sexDictData.getDictValue().equals(enterpriseExamineeScoreVo.getSex())) {
                    enterpriseExamineeScoreVo.setSex(sexDictData.getDictLabel());
                    return;
                }
            });

        });
    }

}
